package com.future.hedongjun.home.bean.response;

import com.future.baselib.entity.BaseResponse;
import com.future.hedongjun.home.bean.ClassHourBean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Date：2018/12/6 14:27
 * author: liu.p.f
 * Describe：
 */
public class ClassHourResponse extends BaseResponse {
    public List<ClassHourBean> data;

    @Override
    public void parseInfo(String content) throws JSONException {
        JSONObject array = new JSONObject(content);
        String classId = array.getString("id");
        String className = array.getString("name");
        String buy_status = array.optString("buy_status");
        String classLogo = array.getString("logo_img");
        String tutorUrl = array.getString("tutor_url");
        String classPrice = array.getString("price");
        JSONArray jsonArray = array.getJSONArray("list");
        data = new ArrayList<>();
        for (int i = 0; i < jsonArray.length(); i++) {
            JSONObject object = jsonArray.optJSONObject(i);
            ClassHourBean bean = new ClassHourBean();
            bean.title = object.optString("title");
            bean.id = object.optString("id");
            bean.onlineId = object.optString("online_id");
            bean.address = object.optString("address");
            bean.mpaddress = object.optString("mpaddress");
            bean.buy_status = buy_status;
            bean.ClassName = className;
            bean.classId = classId;
            bean.classLogo = classLogo;
            bean.tutorUrl = tutorUrl;
            bean.classPrice = classPrice;
            data.add(bean);
        }
    }
}
